﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WPFDemoMVVM.View
{
    /// <summary>
    /// UserInputChildrenView.xaml 的交互逻辑
    /// </summary>
    public partial class UserInputChildrenView : Window
    {
        public UserInputChildrenView()
        {
            InitializeComponent();

            Owner ??= Application.Current.MainWindow;


            this.InputBox.Focus();
            this.InputBox.SelectAll();

        }


        public string? UserInput { get; private set; }

        public UserInputChildrenView(string prompt, string title, string text = "") : this()
        {
            this.promptText.Text = prompt;
            this.Title = title;
            this.InputBox.Text = text;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.InputBox.Text = this.InputBox.Text.Trim();
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}
